package com.qfedu.service.impl;

import com.qfedu.dao.CarMapper;
import com.qfedu.vo.BaseResult;
import com.qfedu.pojo.Car;
import com.qfedu.service.CarService;
import com.qfedu.dao.CarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CarServiceImpl implements CarService {
    @Autowired
    CarMapper carMapper;
    //public BaseResult findCarsByHot(Integer getId) {
    //    List<Car> cars=carMapper.findCarsByHot(getId);
    //    BaseResult baseResult=new BaseResult();
    //    if(cars!=null) {
    //        baseResult.setCode(1);
    //        baseResult.setData(cars);
    //    }
    //    return baseResult;
    //}

    //public BaseResult findCarsByPrice(Integer getId) {
    //    List<Car> cars=carMapper.findCarsByPrice(getId);
    //    BaseResult baseResult=new BaseResult();
    //    if(cars!=null){
    //        baseResult.setCode(1);
    //        baseResult.setData(cars);
    //    }
    //    return baseResult;
    //}

    //public BaseResult findCarById(int id) {
    //    Car car=carMapper.findCarById(id);
    //    BaseResult baseResult=new BaseResult();
    //    baseResult.setData(car);
    //    return baseResult;
    //}

    //public BaseResult addCar(Car car) {
    //    int count=carMapper.addCar(car);
    //    return null;
    //}

    public BaseResult findAll() {
        List<Car> cars=carMapper.queryAll();
        BaseResult baseResult=new BaseResult();
        if(cars!=null){

            baseResult.setData(cars);
            baseResult.setCode(0);
        }
        return baseResult;
    }

    public BaseResult deleteCar(Integer id) {
        int count=carMapper.deleteById(id);
        return null;
    }

    public BaseResult updateCar(Car car) {
        int count=carMapper.update(car);
        return null;
    }
}
